package web.suzy.oj.controller.oj;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import web.suzy.oj.annotation.AnonApi;
import web.suzy.oj.common.result.ResultBean;
import web.suzy.oj.pojo.vo.AnnouncementVO;
import web.suzy.oj.service.oj.HomeService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * YangSuzy 软件工作室
 * 类名: HomeController
 * 描述: 首页功能控制器
 * 功能: 处理首页的请求
 *
 * @author YangSuzy
 * Date: 2022/11/16 19:04
 */
@RestController
@RequestMapping("/api")
@AnonApi
public class HomeController {
    @Autowired
    private HomeService homeService;

    /**
     * 方法名: getWebConfig
     * 描述: 获取网站基本信息和配置
     *
     * @return web.suzy.oj.common.result.ResultBean<java.util.Map < java.lang.Object, java.lang.Object>>
     * @date 2022/11/16 19:06
     * @auther YangSuzy
     **/
    @GetMapping("/get-website-config")
    public ResultBean<Map<Object, Object>> getWebConfig() {
        return homeService.getWebConfig();
    }

    /**
     * 方法名: getCommonAnnouncement
     * 描述: 获取主页公告列表
     *
     * @param limit       每页显示数目
     * @param currentPage 当前页
     * @return web.suzy.oj.common.result.ResultBean<com.baomidou.mybatisplus.core.metadata.IPage < web.suzy.oj.pojo.vo.AnnouncementVO>>
     * @date 2022/11/27 11:41
     * @auther YangSuzy
     **/
    @GetMapping("/get-common-announcement")
    public ResultBean<IPage<AnnouncementVO>> getCommonAnnouncement(
            @RequestParam(value = "limit", required = false) Integer limit,
            @RequestParam(value = "currentPage", required = false) Integer currentPage) {
        return homeService.getCommonAnnouncement(limit, currentPage);
    }

    /**
     * 方法名: getHomeCarousel
     * 描述: 获取主页轮播图
     *
     * @return web.suzy.oj.common.result.ResultBean<java.util.List < java.util.HashMap < java.lang.String, java.lang.Object>>>
     * @date 2022/12/10 18:14
     * @auther YangSuzy
     **/
    @GetMapping("/home-carousel")
    public ResultBean<List<HashMap<String, Object>>> getHomeCarousel() {
        return homeService.getHomeCarousel();
    }
}
